/**
 * Created by mac1 on 2017/11/14.
 */
function setup(format) {
  var regexp = /:(\w+)/g; //使用正则表达式匹配请求属性
  console.log('format -->' + format);
  return function logger(req, res, next) {
    var str = format.replace(regexp, function (match, property) {

      for(var i = 0; i < arguments.length;i ++)
      {
        console.log('argument ' + i + ' ' + arguments[i] + ' ');
      }

      console.log('match ->' + match + ' property ->' + property);
      return req[property];
    });
    console.log('logger ->' + str);
    next();
  }
}

module.exports = setup;